/**
 * @param {number[]} nums1
 * @param {number[]} nums2
 * @param {number[][]} queries
 * @return {number[]}
 */
var maximumSumQueries = function (nums1, nums2, queries) {
  let res = []
  for (let i = 0; i < queries.length; i++) {
    let x = queries[i][0], y = queries[i][1]
    let temp_max = -1
    for (let j = 0; j < nums1.length; j++) {
      if (nums1[j] >= x && nums2[j] >= y) {
        if (nums1[j] + nums2[j] > temp_max) {
          temp_max = nums1[j] + nums2[j]
        }
      }
    }
    res.push(temp_max)
  }
  return res
}
/**
 * 两层循环时间复杂度太高无法通过
 * 时间复杂度为o(n)的方法有无？
 * 
 */
console.log(maximumSumQueries([4, 3, 1, 2], [2, 4, 9, 5], [[4, 1], [1, 3], [2, 5]]))
console.log(maximumSumQueries([2, 1], [2, 3], [[3, 3]]))